
---@class CustomMoveHandler:ActionHandlerBase
CustomMoveHandler = class(ActionHandlerBase)

function CustomMoveHandler:Enter()
    self.base.Enter(self);
    Debug.Log("进入移动动作");
    ---@type UnityEngine.Transform
    self._self = self:GetGameData(ECustomDataName.SelfTrans);
    ---@type UnityEngine.CharacterController
    self._controller = self._self:GetComponent(typeof(CS.UnityEngine.CharacterController));
end

function CustomMoveHandler:Execute()
    self.base.Execute(self);
    local targetPos = self:GetGameData(ECustomDataName.TargetPos)
    if CS.UnityEngine.Vector3.Distance(self._self.position, targetPos) > 1.5 then
        local dirToEnemy = (targetPos - self._self.position).normalized;
        self._controller:SimpleMove(dirToEnemy * 4);
    else
        self:OnComplete();
    end
end
